$(function() {
	$("#select")
			.click(
					function() {

						if ($("#selectType").val() == "订单号") {// 订单号检验

							var cherk = $('#orderid').val();
							var reg = /^[0-9]{10}$/;
							var pattern = new RegExp(reg);
							var t = document.getElementById("t1");
							t.innerHTML = "<tr><td class=\"c1\">订单号</td><td class=\"c1\">门店名称</td><td class=\"c1\">下单商品</td><td class=\"c1\">数量(kg)</td><td class=\"c1\">下单时间</td></tr>";
							t.innerHTML = "<tr><td class=\"c1\">订单号</td><td class=\"c1\">门店名称</td><td class=\"c1\">下单商品</td><td class=\"c1\">数量(kg)</td><td class=\"c1\">下单时间</td></tr>";

							if (pattern.test(cherk)) {// 正则检验是非10位的纯数字

								var xhr = new XMLHttpRequest();
								xhr.onreadystatechange = function() {
									if (xhr.readyState == 4
											&& xhr.status == 200) {
										var data = xhr.responseText;
										var obj = JSON.parse(data);
										t.innerHTML += "<tr><td>" + obj.orderid
												+ "</td><td>" + obj.shopid
												+ "</td><td>" + obj.goodsname
												+ "</td><td>" + obj.goodsnum
												+ "</td><td>" + obj.createtime
												+ "</td></tr>";

									}
								}
								xhr.open('get', '/order/selectById?orderid='
										+ $('#orderid').val(), true);
								xhr.send();
							} else {

								t.innerHTML += "<tr><td colspan=\"5\">订单号错误，请检查是否输入正确！！！</td></tr>";

							}

						} else if ($("#selectType").val() == "门店名称") {// 店名检验订单号检验
							alert("门店名称");
						} else {

							alert("下单商品");
						}

					});
});
